﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Core.Log;

namespace Core.Xml.Ogc.Ows
{
    class TelephoneType : IXmlType
    {
        public List<string> Voice { get; set; }

        public List<string> Facsimile { get; set; }

        public XElement CreateXElement(XName elementName)
        {
            XElement telephone = new XElement(elementName);

            if ((Voice == null || Voice.Count == 0) && (Facsimile == null || Facsimile.Count == 0))
            {
                Logger logger = Logger.GetInstance();
                logger.Add(new BasicLog(LogPriority.WARNING, "Telephone type element is empty. It should be removed."));
            }
            if (Voice == null || Voice.Count == 0)
            {
                for (int i = 0; i < Voice.Count; i++)
                {
                    telephone.Add(new XElement(Namespaces.OWS + "Voice", Voice[i]));
                }
            }

            if (Facsimile == null || Facsimile.Count == 0)
            {
                for (int i = 0; i < Facsimile.Count; i++)
                {
                    telephone.Add(new XElement(Namespaces.OWS + "Facsimile", Voice[i]));
                }
            }

            return telephone;
        }
    }
}
